package com.capgemini.diabeo.model;

import android.database.sqlite.SQLiteDatabase;

import java.util.Map;

import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.AbstractDaoSession;
import de.greenrobot.dao.identityscope.IdentityScopeType;
import de.greenrobot.dao.internal.DaoConfig;

import com.capgemini.diabeo.model.Menu;
import com.capgemini.diabeo.model.Category;
import com.capgemini.diabeo.model.Dish;
import com.capgemini.diabeo.model.MenuDish;

import com.capgemini.diabeo.model.MenuDao;
import com.capgemini.diabeo.model.CategoryDao;
import com.capgemini.diabeo.model.DishDao;
import com.capgemini.diabeo.model.MenuDishDao;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.

/**
 * {@inheritDoc}
 * 
 * @see de.greenrobot.dao.AbstractDaoSession
 */
public class DaoSession extends AbstractDaoSession {

    private final DaoConfig menuDaoConfig;
    private final DaoConfig categoryDaoConfig;
    private final DaoConfig dishDaoConfig;
    private final DaoConfig menuDishDaoConfig;

    private final MenuDao menuDao;
    private final CategoryDao categoryDao;
    private final DishDao dishDao;
    private final MenuDishDao menuDishDao;

    public DaoSession(SQLiteDatabase db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
            daoConfigMap) {
        super(db);

        menuDaoConfig = daoConfigMap.get(MenuDao.class).clone();
        menuDaoConfig.initIdentityScope(type);

        categoryDaoConfig = daoConfigMap.get(CategoryDao.class).clone();
        categoryDaoConfig.initIdentityScope(type);

        dishDaoConfig = daoConfigMap.get(DishDao.class).clone();
        dishDaoConfig.initIdentityScope(type);

        menuDishDaoConfig = daoConfigMap.get(MenuDishDao.class).clone();
        menuDishDaoConfig.initIdentityScope(type);

        menuDao = new MenuDao(menuDaoConfig, this);
        categoryDao = new CategoryDao(categoryDaoConfig, this);
        dishDao = new DishDao(dishDaoConfig, this);
        menuDishDao = new MenuDishDao(menuDishDaoConfig, this);

        registerDao(Menu.class, menuDao);
        registerDao(Category.class, categoryDao);
        registerDao(Dish.class, dishDao);
        registerDao(MenuDish.class, menuDishDao);
    }
    
    public void clear() {
        menuDaoConfig.getIdentityScope().clear();
        categoryDaoConfig.getIdentityScope().clear();
        dishDaoConfig.getIdentityScope().clear();
        menuDishDaoConfig.getIdentityScope().clear();
    }

    public MenuDao getMenuDao() {
        return menuDao;
    }

    public CategoryDao getCategoryDao() {
        return categoryDao;
    }

    public DishDao getDishDao() {
        return dishDao;
    }

    public MenuDishDao getMenuDishDao() {
        return menuDishDao;
    }

}
